var t = getApp(), a = require("../../provider/dataApi.js"), e = (require("../../provider/pipe.js"), 
require("../../wxParse/wxParse.js"));

Page({
    data: {
        special_id: "",
        isAnalysisAudioPlay: 1,
        answerAudiolist: [],
        answerImglist: [],
        isfirstPlay: !0,
        have: 1,
        type: 1,
        startPoint: [ 0, 0 ],
        curPoint: [],
        statusBarHeight: "",
        titleBarHeight: "",
        show: !1,
        num: 0,
        num_length: 0,
        remainder: 0,
        handpapershow: !1,
        item: {
            total_score: 100,
            pass_score: 60,
            paper_time: 90,
            highest: 0
        },
        timer: null,
        ruletime: "",
        durationtime: "",
        usetime: "",
        index: 0,
        paperdetail: "",
        answerlist: [],
        audiolist: [],
        answerlength: 0,
        isaudio: 1,
        inputHeight: 0,
        rightAnswer: [],
        isloading: !1,
        adInfo: {},
        ad_have: 2,
        userAnswerJudge: [],
        trialBool: !1,
        trialNum: "",
        isPageWait: !0,
        titlePlayTime: "00:00",
        titleTotalTime: "00:00",
        titleAudioTimer: null,
        analysisPlayTime: "00:00",
        analysisTotalTime: "00:00",
        analysisAudioTimer: null,
        audioTimeList: [],
        isShowShortAnswer: !1
    },
    previewImg: function(t) {
        var a = this.data.paperdetail[this.data.index].qimage;
        wx.previewImage({
            current: a[t.currentTarget.dataset.index],
            urls: a
        });
    },
    goLx: function() {
      /*  var t = this.data.isCanAnswer;
       a.globalData.op = "sequence", wx.getStorageSync("uid") ? t ? (a.globalData.id = "", 
       wx.navigateTo({
           //url: "/pages/quesBankType/quesBankType"
           url: "/pages/keyi/keyi"
       })) : this.testInfo() : wx.navigateTo({
           url: "../login/login"
       }); */
       wx.navigateBack()
   },
    previewImgJx: function(t) {
        var a = this.data.paperdetail[this.data.index].aimage;
        wx.previewImage({
            current: a[t.currentTarget.dataset.index],
            urls: a
        });
    },
    mytouchstart: function(t) {
        this.setData({
            startPoint: [ t.touches[0].pageX, t.touches[0].pageY ]
        });
    },
    mytouchmove: function(t) {
        this.setData({
            curPoint: [ t.touches[0].pageX, t.touches[0].pageY ]
        });
    },
    mytouchend: function(t) {
        t.changedTouches[0].pageX - this.data.startPoint[0] < 0 ? this.data.index + 1 < this.data.paperdetail.length && this.setData({
            index: this.data.index + 1
        }) : 0 < this.data.index && this.setData({
            index: this.data.index - 1
        });
    },
    goType: function(t) {
        t = t.currentTarget.dataset.type;
        var a = this.data.answerlist, e = !1;
        2 == t && (e = !0), a[this.data.index].isanalysis = e, this.setData({
            type: t,
            answerlist: a
        });
    },
    onLoad: function(a) {
        if (wx.getStorageSync("uid")) {
            if (this.setData({
                statusBarHeight: getApp().globalData.statusBarHeight,
                titleBarHeight: getApp().globalData.titleBarHeight
            }), "{}" != JSON.stringify(a)) {
                console.log(a);
                var e = "";
                a.sonType && (e = a.sonType), this.setData({
                    trialNum: a.num,
                    trialBool: !0,
                    sonType: e
                });
            }
            a = !0, "seeErr" == t.globalData.op && (a = !1), this.setData({
                isShowShortAnswer: a
            }), a = t.globalData.op, console.log(t.globalData.id), e = t.globalData.id, "sequence" == a || "randoms" == a || "notdone" == a || "qtype" == a ? this.mockExam(a, e, 13) : this.mockExam(a, e, ""), 
            this.queryAd();
        } else wx.navigateTo({
            url: "/pages/login/login"
        });
    },
    queryAd: function() {
        var t = this;
        a.advert({
            op: "second"
        }).then(function(a) {
            t.setData({
                adInfo: a.data.info,
                ad_have: a.data.ad_have
            });
        }).catch(function(t) {
            console.log(t);
        });
    },
    goBack: function() {
        2 != this.data.have && this.changepic(this.data.index), wx.navigateBack({
            delta: 1
        });
    },
    showTk: function() {
        if (100 < this.data.paperdetail) {
            var t = Math.floor(this.data.paperdetail.length / 100), a = this.data.paperdetail.length % 100;
            console.log(t, a), this.setData({
                num: 100,
                num_length: t,
                remainder: a
            });
        } else this.setData({
            num: this.data.paperdetail
        });
        this.setData({
            show: !0
        });
    },
    onClose: function() {
        this.setData({
            show: !1
        });
    },
    goUp: function() {
        if (0 == this.data.index) return !1;
        this.setData({
            index: this.data.index - 1
        });
        var t = {};
        this.setData((t["answerlist[" + (this.data.index + 1) + "].isanalysis"] = !1, t.isPageWait = !0, 
        t)), this.judgeShortAnswer(), this.changepic(this.data.index), this.initUserAnswer(this.data.index), 
        this.wxParseTitle(this.data.index), this.clearAudioTime();
    },
    goDown: function() {
        if (this.data.trialBool) {
            var t = this.data.trialNum;
            if (this.data.index + 1 >= t) return wx.showToast({
                title: "本套试题只能试答" + t + "题哦~",
                icon: "none"
            }), !1;
        }
        if (this.data.index + 1 >= this.data.paperdetail.length) return wx.showToast({
            title: "已做完所有习题",
            icon: "none"
        }), !1;
        this.setData({
            index: this.data.index + 1,
            isPageWait: !0
        }), t = {}, this.setData((t["answerlist[" + (this.data.index - 1) + "].isanalysis"] = !1, 
        t)), this.judgeShortAnswer(), this.changepic(this.data.index), this.initUserAnswer(this.data.index), 
        this.wxParseTitle(this.data.index), this.clearAudioTime();
    },
    jumptap: function(t) {
        if (this.data.trialBool) {
            var a = t.currentTarget.dataset.i;
            if (console.log(a), a >= this.data.trialNum) return wx.showToast({
                title: "此为试答，如想答剩下的题请先去购买此套试卷哦",
                icon: "none"
            }), !1;
        }
        this.setData({
            index: t.currentTarget.dataset.i,
            show: !1,
            isPageWait: !0
        }), this.judgeShortAnswer(), this.changepic(this.data.index), this.initUserAnswer(this.data.index), 
        this.wxParseTitle(this.data.index), this.clearAudioTime();
    },
    judgeShortAnswer: function() {
        var t = this.data.isShowShortAnswer;
        8 == this.data.paperdetail[this.data.index].type && (t ? this.setData({
            type: 1
        }) : this.setData({
            type: 2
        }));
    },
    initUserAnswer: function(t) {
        if (4 == (a = this.data.paperdetail)[t].type) {
            t = a[t].rightarray;
            for (var a = [], e = 0; e < t.length; e++) a.push(!0);
            this.setData({
                userAnswerJudge: a
            });
        }
    },
    scrolltolower: function(t) {
        this.data.num < this.data.paperdetail.length && (Math.floor(this.data.num / 100) == this.data.num_length ? this.setData({
            num: this.data.num + this.data.remainder
        }) : this.setData({
            num: this.data.num + 100
        }));
    },
    addWrong: function() {
        var t = this;
        a.addWrong({
            uid: wx.getStorageSync("uid"),
            tid: this.data.paperdetail[this.data.index].id,
            test_type: this.data.paperdetail[this.data.index].type,
            wrong_have: this.data.paperdetail[this.data.index].wrong_have
        }).then(function(a) {
            console.log(a);
            var e = "paperdetail[" + t.data.index + "].wrong_have";
            1 == a.data ? (wx.showToast({
                title: "已加入收藏",
                icon: "none"
            }), a = {}, t.setData((a[e] = 1, a))) : (wx.showToast({
                title: "已移出收藏",
                icon: "none"
            }), a = {}, t.setData((a[e] = 2, a)));
        }).catch(function(t) {
            console.log(t);
        });
    },
    choice: function(t) {
        var a = this.data.answerlist, e = 0;
        a[t.currentTarget.dataset.fjtit].choose = t.currentTarget.dataset.option, a.forEach(function(t) {
            2 == t.type ? t.flag && e++ : 4 == t.type ? t.issure && e++ : 5 == t.type ? t.iscomplete && e++ : t.choose && e++;
        }), this.setData({
            answerlist: a,
            answerlength: e
        }), this.judge(this.data.index), this.recordAnswer();
    },
    multipleChoice: function(t) {
        var a = t.currentTarget.dataset.fjtit, e = t.currentTarget.dataset.option, i = 0, s = 0;
        (t = this.data.answerlist)[a].choose.forEach(function(t, a) {
            t.o == e && (t.ischoose = !t.ischoose);
        });
        for (var n = 0; n < t[a].choose.length; n++) {
            if (t[a].choose[n].ischoose) {
                i = 1, t[a].flag = !1;
                break;
            }
            i = 0, t[a].flag = !1;
        }
        t.forEach(function(t) {
            2 == t.type ? t.flag && s++ : 4 == t.type ? t.issure && s++ : 5 == t.type ? t.iscomplete && s++ : t.choose && s++;
        }), t[a].flag = 1 == i, this.setData({
            answerlength: s + i,
            answerlist: t
        });
    },
    gomultipleChoice: function(t) {
        var a = t.currentTarget.dataset.fjtit, e = this.data.answerlist, i = t.currentTarget.dataset.item, s = [];
        e[a].choose.forEach(function(t) {
            t.ischoose && s.push(t.o);
        }), (s = s.join(",")) == i.rightkey && (e[a].isright = !0), 0 < s.length ? (e[a].issure = !0, 
        i.rightkey = i.rightkey.split(","), e[a].choose.forEach(function(t) {
            t.ischoose ? -1 != i.rightkey.indexOf(t.o) ? t.ischooseright = 1 : -1 == i.rightkey.indexOf(t.o) && (t.ischooseright = 2) : -1 != i.rightkey.indexOf(t.o) ? t.ischooseright = 3 : -1 == i.rightkey.indexOf(t.o) && (t.ischooseright = 4);
        }), this.setData({
            answerlist: e
        }), this.judge(this.data.index), this.recordAnswer()) : wx.showToast({
            icon: "none",
            title: "请选择你的答案~"
        });
    },
    textInput: function(t) {
        var a = t.currentTarget.dataset.fjnum, e = this.data.answerlist;
        e[a].choose[t.currentTarget.dataset.inputnum] = t.detail.value;
        var i = 0;
        this.isempty(e[a].choose) ? e[a].issure = !0 : e[a].issure = !1, e.forEach(function(t) {
            2 == t.type ? t.flag && i++ : 4 == t.type ? t.issure && i++ : 5 == t.type ? t.iscomplete && i++ : t.choose && i++;
        }), this.setData({
            answerlist: e,
            answerlength: i
        });
    },
    goSure: function(t) {
        t = t.currentTarget.dataset.fjnum;
        var a = this.data.answerlist;
        console.log(t), console.log(this.data.index), console.log(a), a[t] && this.isempty(a[t].choose) ? (a[t].iswrite = !0, 
        this.setData({
            answerlist: a
        }), this.judge(this.data.index), this.recordAnswer()) : wx.showToast({
            icon: "none",
            title: "请填写完整~"
        });
    },
    judgeCompletionItem: function() {
        for (var t = this.data.index, a = this.data.paperdetail[t].rightkey.split("|"), e = this.data.answerlist[t].choose, i = (t = [], 
        a = a.map(function(t) {
            return t.replace(/\u3011\u3010/g, "】,【");
        }).map(function(t) {
            return t.split(",");
        }), e = e.map(function(t) {
            return "【" + t + "】";
        }), 0); i < e.length; i++) {
            for (var s = !1, n = 0; n < a.length; n++) e[i] == a[n][i] && (s = !0);
            t.push(s);
        }
        this.setData({
            userAnswerJudge: t
        });
    },
    vioceChoice: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.fjnum, e = this.data.answerlist, i = 0, s = {};
        this.setData((s["answerlist[" + a + "].choose[" + t.currentTarget.dataset.zjnum + "].choose"] = t.currentTarget.dataset.option, 
        s)), this.isempty(e[a].choose) ? e[a].iscomplete = !0 : e[a].iscomplete = !1, e.forEach(function(t) {
            2 == t.type ? t.flag && i++ : 4 == t.type ? t.issure && i++ : 5 == t.type ? t.iscomplete && i++ : t.choose && i++;
        }), console.log(e), this.setData({
            answerlist: e,
            answerlength: i
        }), this.isBigjudge(a), this.recordAnswer();
    },
    chooseOption: function(t) {
        var a = this.data.index, e = this.data.answerlist;
        e[a].choose[t.currentTarget.dataset.findex].userAnswer = t.currentTarget.dataset.zindex, 
        console.log(e[a].choose), this.setData({
            answerlist: e
        }), this.isBigjudge(a), this.recordAnswer();
    },
    isBigjudge: function(t) {
        var a = this.data.answerlist, e = a[t], i = e.choose.length, s = !0;
        if (5 == e.type) {
            for (var n = 0; n < i; n++) if ("" == e.choose[n].choose) return;
            for (n = 0; n < i; n++) e.choose[n].isright != e.choose[n].choose && (s = !1);
        }
        if (6 == a[t].type || 7 == a[t].type) {
            for (n = 0; n < i; n++) if ("" == e.choose[n].userAnswer) return;
            for (n = 0; n < i; n++) e.choose[n].isright != e.choose[n].userAnswer && (s = !1);
        }
        a[t].isjudge = s ? 1 : 2, this.setData({
            answerlist: a
        });
    },
    bindShortAnswerBlur: function(t) {
        var a = this.data.answerlist;
        a[this.data.index].choose = t.detail.value, this.setData({
            answerlist: a
        });
    },
    shortAnswerSure: function(t) {
        console.log(this.data.answerlist), t = this.data.answerlist;
        var a = this.data.index;
        "" == t[a].choose ? wx.showToast({
            icon: "none",
            title: "请先输入您的答案"
        }) : (t[a].isanalysis = !0, t[a].issure = !0, this.setData({
            answerlist: t
        }), this.pageScrollTo("#analysis"), this.lookAnaiysis());
    },
    pageScrollTo: function(t) {
        var a = wx.createSelectorQuery();
        a.selectViewport().scrollOffset(), a.select(t).boundingClientRect(), a.exec(function(t) {
            console.log(t), wx.pageScrollTo({
                scrollTop: t[0].scrollTop + t[1].top - 500,
                duration: 300
            });
        });
    },
    onReady: function() {
        var t = wx.createInnerAudioContext();
        this.setData({
            audioCtx: t
        });
    },
    onHide: function() {
        this.changepic(this.data.index), wx.createVideoContext([ "index", this.data.playIndex ].join("")).pause();
    },
    onUnload: function() {
        this.changepic(this.data.index), wx.createVideoContext([ "index", this.data.playIndex ].join("")).pause();
        var t = clearInterval(this.data.titleAudioTimer), a = clearInterval(this.data.analysisAudioTimer);
        this.setData({
            titleAudioTimer: t,
            analysisAudioTimer: a
        });
    },
    goCorrection: function(a) {
        t.globalData.id = a.currentTarget.id, wx.navigateTo({
            url: "../feedback/feedback"
        });
    },
    bindplay: function(t) {
        if (console.log(t), t = t.currentTarget.id, this.data.playIndex) {
            var a = wx.createVideoContext([ "index", this.data.playIndex ].join(""));
            a.seek(0), a.pause(), console.log([ "index", this.data.playIndex ].join("")), this.setData({
                playIndex: t
            }), console.log([ "index", this.data.playIndex ].join("")), wx.createVideoContext([ "index", this.data.playIndex ].join("")).play();
        } else this.setData({
            playIndex: t
        }), wx.createVideoContext([ "index", t ].join("")).play();
    },
    mockExam: function(e, i, s) {
        var n = this;
        this.setData({
            isloading: !0
        });
        var o = "";
        t.globalData.paperId && (o = t.globalData.paperId), console.log(e), a.sequence({
            uid: wx.getStorageSync("uid"),
            typeId: i,
            son_type: this.data.sonType,
            op: e,
            paperid: o,
            lib_id: s
        }).then(function(t) {
            if (console.log(t), t.data.list.length <= 0) n.setData({
                have: t.data.have,
                isloading: !1
            }); else {
                var a = [], e = [], i = [], s = [], o = [], r = [];
                t.data.list && (t.data.list.forEach(function(t) {
                    if (1 == t.type || 3 == t.type || 8 == t.type) a.push({
                        type: t.type,
                        tid: t.id,
                        issure: !1,
                        choose: "",
                        isanalysis: !1,
                        isjudge: 3
                    }); else if (2 == t.type) {
                        var n = t.rightkey.split(","), d = [];
                        t.option.forEach(function(t) {
                            d.push({
                                o: t.o,
                                ischoose: !1
                            });
                        }), a.push({
                            type: t.type,
                            tid: t.id,
                            issure: !1,
                            flag: !1,
                            choose: d,
                            isanalysis: !1,
                            isjudge: 3
                        }), t.option.forEach(function(t) {
                            -1 != n.indexOf(t.o) ? t.right = !0 : t.right = !1;
                        });
                    } else if (4 == t.type) {
                        for (var h = [], l = 0; l < t.rightarray.length; l++) h.push("");
                        a.push({
                            type: t.type,
                            tid: t.id,
                            issure: !1,
                            choose: h,
                            iswrite: !1,
                            isanalysis: !1,
                            isjudge: 3
                        });
                    } else if (5 == t.type) {
                        var u = [], c = [];
                        t.list.forEach(function(t) {
                            u.push({
                                tid: t.id,
                                isright: t.rightkey,
                                choose: ""
                            }), c.push(t.rightkey);
                        }), t.rightkey = c.join(","), a.push({
                            type: t.type,
                            tid: t.id,
                            iscomplete: !1,
                            choose: u,
                            isanalysis: !1,
                            isjudge: 3
                        });
                    } else if (6 == t.type || 7 == t.type) {
                        var p = [];
                        t.list instanceof Array && 0 < t.list.length && (h = t.list.map(function(t, a) {
                            return p.push(t.rightkey), {
                                tid: t.id,
                                isright: t.rightkey,
                                userAnswer: ""
                            };
                        }), t.rightkey = p.join(","), a.push({
                            type: t.type,
                            tid: t.id,
                            issure: !1,
                            choose: h,
                            isanalysis: !1,
                            isDo: !1,
                            isjudge: 3
                        }));
                    } else 8 == t.type && "" == t.uanswer && (t.uanswer = "暂未作答");
                    t.qaudio ? e.push({
                        audiosrc: t.qaudio,
                        time: 0
                    }) : e.push({
                        audiosrc: "",
                        time: 0
                    }), 2 == t.a_type ? i.push(t.option) : i.push(""), 4 == t.type ? s.push(t.rightarray.join(",")) : s.push(t.rightkey), 
                    t.analysis_audio ? o.push({
                        audiosrc: t.analysis_audio,
                        time: 0
                    }) : o.push({
                        audiosrc: "",
                        time: 0
                    }), r.push(t.aimage);
                }), console.log(t.data.list), t.data.list && n.setData({
                    paperdetail: t.data.list,
                    answerlist: a,
                    audiolist: e,
                    rightAnswer: s,
                    answerAudiolist: o,
                    answerImglist: r
                }), t.data.last_id && n.setData({
                    index: Number(t.data.last_id)
                }), n.setData({
                    isloading: !1
                }), n.getAllAudioTime(), n.judgeShortAnswer(), n.wxParseTitle(n.data.index));
            }
        }).catch(function(t) {
            n.setData({
                isloading: !1
            }), console.log(t);
        });
    },
    getAllAudioTime: function() {
        var t = [];
        this.data.paperdetail.forEach(function() {
            t.push({
                title: "00:00",
                analysis: "00:00"
            });
        }), this.setData({
            audioTimeList: t
        });
    },
    wxParseTitle: function(t) {
        t = this.data.paperdetail[t], e.wxParse("ParseTitle", "html", t.question, this, 5), 
        console.log(this.data.ParseTitle), 0 != t.a_type || 1 != t.type && 2 != t.type ? this.setData({
            isPageWait: !1
        }) : this.wxParseOptions(t.option);
    },
    wxParseOptions: function(t) {
        for (var a = 0; a < t.length; a++) e.wxParse("wxParseOption" + a, "html", t[a].p, this);
        this.setData({
            isPageWait: !1
        });
    },
    isempty: function(t) {
        var a;
        for (var e in new Boolean(), a = !0, t) t[e] || (a = !1);
        return !!a;
    },
    lookAnaiysis: function() {
        var t = this.data.answerlist, a = this.data.index;
        t[a].isanalysis || (t[a].isanalysis = !0, this.setData({
            answerlist: t
        }), console.log(this.data.paperdetail[a].analysis), e.wxParse("article", "html", this.data.paperdetail[a].analysis, this, 15));
    },
    changepic: function(t) {
        2 != this.data.have && 0 != this.data.audiolist.length && (!this.data.audiolist[t].url || this.data.audiolist[t].url != this.data.audiolist[t - 1].url && 0 < t) && (this.setData({
            isaudio: 1,
            isAnalysisAudioPlay: 1
        }), this.data.audioCtx.pause());
    },
    myAudioStart: function(t) {
        var a = this.data.audioCtx, e = this, i = t.currentTarget.dataset.type;
        if (console.log("播放解析=" + i), "paper" == i) {
            var s = clearInterval(this.data.analysisAudioTimer);
            this.setData({
                isaudio: 2,
                isAnalysisAudioPlay: 1,
                analysisPlayTime: "00:00",
                analysisAudioTimer: s
            }), a.src = t.currentTarget.dataset.src, a.play(), this.currenttime(), this.data.onEnded || (this.data.onEnded = !0, 
            a.onEnded(function() {
                e.setData({
                    isaudio: 1,
                    currentTime: 0
                }), e.audiotime(t.currentTarget.dataset.src, 0);
            }));
            var n = t.currentTarget.dataset.num, o = e.data.audioTimeList, r = setInterval(function() {
                var t = Math.round(a.currentTime), i = Math.round(a.duration), s = e.handleTime(t), d = e.handleTime(i);
                o[n].title = d, e.setData({
                    titlePlayTime: s,
                    titleTotalTime: d,
                    audioTimeList: o,
                    titleAudioTimer: r
                }), i == t && (console.log("停止"), setTimeout(function() {
                    clearInterval(r), e.setData({
                        titlePlayTime: "00:00",
                        titleTotalTime: d,
                        titleAudioTimer: r
                    });
                }, 1e3));
            }, 1e3);
        }
        if ("analysis" == i) {
            i = clearInterval(this.data.titleAudioTimer), this.setData({
                isAnalysisAudioPlay: 2,
                isaudio: 1,
                titlePlayTime: "00:00",
                titleAudioTimer: i
            }), a.src = t.currentTarget.dataset.src, a.play(), this.currenttime(), this.data.onEnded || (this.data.onEnded = !0, 
            a.onEnded(function() {
                e.setData({
                    isAnalysisAudioPlay: 1,
                    currentTime: 0
                }), e.audiotime(t.currentTarget.dataset.src, 0);
            }));
            var d = t.currentTarget.dataset.num, h = e.data.audioTimeList, l = setInterval(function() {
                var t = Math.round(a.currentTime), i = Math.round(a.duration), s = e.handleTime(t), n = e.handleTime(i);
                h[d].analysis = n, e.setData({
                    analysisPlayTime: s,
                    analysisTotalTime: n,
                    audioTimeList: h,
                    analysisAudioTimer: l
                }), i == t && (console.log("停止"), setTimeout(function() {
                    clearInterval(l), e.setData({
                        analysisPlayTime: "00:00",
                        analysisTotalTime: n,
                        analysisAudioTimer: l
                    });
                }, 1e3));
            }, 1e3);
        }
    },
    myAudioPause: function(t) {
        var a = this.data.audioCtx, e = this;
        a.pause();
        var i = t.currentTarget.dataset.type;
        if (console.log("暂停解析=" + i), "paper" == i) {
            a.onPause(function() {
                a.currentTime, e.setData({
                    isaudio: 1
                }), e.audiotime(t.currentTarget.dataset.src, Math.floor(a.currentTime));
            });
            var s = clearInterval(e.data.titleAudioTimer);
            e.setData({
                titleAudioTimer: s
            });
        }
        "analysis" == i && a.onPause(function() {
            a.currentTime, e.setData({
                isAnalysisAudioPlay: 1
            }), e.audiotime(t.currentTarget.dataset.src, Math.floor(a.currentTime));
        });
    },
    handleTime: function(t) {
        if (60 <= t) {
            var a = parseInt(t / 60 % 60);
            return (a < 10 ? "0" + a : a) + ":" + ((t = parseInt(t % 60)) < 10 ? "0" + t : t);
        }
        return "00:" + (t < 10 ? "0" + t : t);
    },
    clearAudioTime: function() {
        var t = this.data.index, a = this.data.audioTimeList, e = a[t].title;
        t = a[t].analysis, clearInterval(this.data.titleAudioTimer), clearInterval(this.data.analysisAudioTimer), 
        this.setData({
            titlePlayTime: "00:00",
            titleTotalTime: e,
            analysisPlayTime: "00:00",
            analysisTotalTime: t
        });
    },
    currenttime: function(t) {
        var a = this.data.audioCtx;
        setTimeout(function() {
            a.currentTime, a.onTimeUpdate(function() {});
        }, 100);
    },
    audiotime: function(t, a) {
        this.data.audiolist.forEach(function(e) {
            e.audiosrc == t && (e.time = a);
        });
    },
    judge: function(t) {
        var a = this.data.answerlist, e = this.data.rightAnswer, i = "";
        if (2 == a[t].type) {
            var s = [];
            a[t].choose.forEach(function(t) {
                t.ischoose && s.push(t.o);
            }), i = s.join(",");
        } else 4 == a[t].type ? i = a[t].choose.join(",") : 1 != a[t].type && 3 != a[t].type || (i = a[t].choose);
        i && (a[t].isjudge = i == e[t] ? 1 : 2), this.setData({
            answerlist: a
        });
    },
    recordAnswer: function() {
        var e = this, i = this.data.answerlist, s = this.data.index, n = [], o = "";
        i.forEach(function(t) {
            if (1 == t.type || 3 == t.type || 3 == t.type) n.push({
                tid: t.tid,
                type: t.type,
                answer: t.choose
            }); else if (2 == t.type) {
                var a = [];
                t.choose.forEach(function(t) {
                    t.ischoose && a.push(t.o);
                }), n.push({
                    tid: t.tid,
                    type: t.type,
                    answer: a
                });
            } else if (4 == t.type) {
                var e = [];
                t.choose.forEach(function(t) {
                    e.push("【" + t + "】");
                }), e = e.join(","), n.push({
                    tid: t.tid,
                    type: t.type,
                    answer: e
                });
            } else if (5 == t.type) {
                var i = [];
                t.choose.forEach(function(t) {
                    i.push({
                        tid: t.tid,
                        answer: t.choose
                    });
                }), n.push({
                    tid: t.tid,
                    type: t.type,
                    answer: i
                });
            } else if (6 == t.type || 7 == t.type) {
                var s = [];
                t.choose.forEach(function(t) {
                    s.push({
                        tid: t.tid,
                        answer: t.userAnswer
                    });
                }), n.push({
                    tid: t.tid,
                    type: t.type,
                    answer: s
                });
            }
        });
        var r = "", d = "";
        "sequence" == t.globalData.op ? o = "shunxu" : "qhigh" == t.globalData.op ? o = "qhigh" : "intensive" == t.globalData.op ? o = "intensive" : "special" == t.globalData.op || "qspecial" == t.globalData.op ? (o = "qspecial", 
        r = this.data.special_id) : "qtype" == t.globalData.op || "qtype_submit" == t.globalData.op ? (o = "qtype_submit", 
        d = this.data.special_id) : o = "other", a.sequence_submit({
            uid: wx.getStorageSync("uid"),
            answerdata: JSON.stringify(n[this.data.index]),
            op: o,
            index: this.data.index,
            special_id: r,
            type_id: d
        }).then(function(t) {
            console.log(t), 4 == i[s].type && e.judgeCompletionItem();
        }).catch(function(t) {
            console.log(t);
        });
    },
    onShareAppMessage: function() {
        return {
            path: "/pages/home/home"
        };
    }
});